(function () {
    angular.module('KtotApp').controller('HomeController',['TaskService', function (taskService) {
        var self = this;        
        self.projects = [];

        self.isSideBarVisible = false;

        self.showSideBar = function () {
            self.refreshProjects();
            self.isSideBarVisible = true;
        };

        self.hideSideBar = function () {
            self.isSideBarVisible = false;
        };

        self.init = function () {
            self.refreshProjects();
        };

        self.refreshProjects = function () {
            taskService.getProjects().then(function (projects) {
                self.projects = projects;
            });
        };
    }]);
})();